package main

import "fmt"

/* 1672. 最富有客户的资产总量 ，https://leetcode.cn/problems/richest-customer-wealth/*/

func ExecQ1672() {
	accounts1 := make([][]int, 0)
	accounts1 = append(accounts1, []int{1, 2, 3})
	accounts1 = append(accounts1, []int{3, 2, 1})
	fmt.Println(maximumWealth(accounts1))

	accounts2 := make([][]int, 0)
	accounts2 = append(accounts2, []int{1, 5})
	accounts2 = append(accounts2, []int{7, 3})
	accounts2 = append(accounts2, []int{3, 5})
	fmt.Println(maximumWealth(accounts2))

	accounts3 := make([][]int, 0)
	accounts3 = append(accounts3, []int{2, 8, 7})
	accounts3 = append(accounts3, []int{7, 1, 3})
	accounts3 = append(accounts3, []int{1, 9, 5})
	fmt.Println(maximumWealth(accounts3))
}

// 我写的^_^官方的
func maximumWealth(accounts [][]int) int {
	max := 0
	for _, account := range accounts {
		count := 0
		for _, val := range account {
			count += val
		}
		if count > max {
			max = count
		}
	}
	return max
}
